document.addEventListener("deviceready", onDeviceReady, false);
var debugAlert = true
var db = window.openDatabase("FitGym_DB", "1.0", "FitGym DB", 200000); //Crea o apre il db FitGym_DB
//onDeviceReady();
//function will be called when device ready
function inizialize(){
    db.transaction(populateDB, errorCB, successCB);
}

//create table and insert some record
function createTableDB(tx) {
	//Crea la tabella di configurazione
	tx.executeSql('CREATE TABLE IF NOT EXISTS Config (id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT NOT NULL, value TEXT NOT NULL)');
}
function popolateTable(tx) {
    tx.executeSql('SELECT value FROM Config WHERE key = "init"', );
    tx.executeSql('INSERT INTO Config(key,value) VALUES ("init", "true")');
}

//function will be called when an error occurred
function errorCB(err) {
    alert("Error processing SQL: "+err.code);
}

//function will be called when process succeed
function successCB() {
	if(debugAlert)
		alert("success!");
    db.transaction(queryDB,errorCB);
}
/*
//select all from SoccerPlayer
function queryDB(tx){
    tx.executeSql('SELECT * FROM SoccerPlayer ',[],querySuccess,errorCB);
}

function querySuccess(tx,results){
    $('#SoccerPlayerList').empty();
//     $.each(results.rows.length,function(i){
//          var row = results.rows.item(i).data;
//          $('#SoccerPlayerList').append('<li><a href="#"><h3 class="ui-li-heading">'+row['Name']+'</h3><p class="ui-li-desc">Club '+row['Club']+'</p></a></li>');
//     });
    var len = results.rows.length;
    for (var i=0; i<len; i++){
    	var row = results.rows.item(i);
//         console.log("Row = " + i + " ID = " + results.rows.item(i).id + " Data =  " + results.rows.item(i).name);
    	$('#SoccerPlayerList').append('<li><a href="#"><h3 class="ui-li-heading">'+row['Name']+'</h3><p class="ui-li-desc">Club '+row['Club']+'</p></a></li>');
    }

    $('#SoccerPlayerList').listview();
}

*/s